package com.study.mapview

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.View
import android.widget.Toast
import com.jdfarm.common.OnMapLoadComplete
import com.jdfarm.tiandimap.MapView

class MainActivity : AppCompatActivity() {
    lateinit var mapView: MapView
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        initMyMapView()
    }

    //自定义地图展示
    private fun initMyMapView() {
        mapView = findViewById(R.id.map)
        mapView.setOnMapLoadListener(object : OnMapLoadComplete {
            override fun onComplete() {
                onMapLoadComplete()
            }
        })
    }

    //地图加载完成
    private fun onMapLoadComplete() {
        toast("加载完成")
    }

    //地图放大
    fun toBig(view: View) {
        mapView.zoomToLarge()
    }

    //地图缩小
    fun toSmall(view: View) {
        mapView.zoomToSmall()
    }

    private fun toast(msg: String) {
        Toast.makeText(this, msg, Toast.LENGTH_SHORT).show()
    }
}